{% from "macros.jinja" import panel_jsontree, panel_jsontree_js, render_trees %}
{% extends "job_result.html" %}

{% block job_result %}

  <div class="row">
    <div class="col-lg-12">
      <h3> Minions:
      </h3>
      <div class="list-group">
        {% for minion in job.info.Minions %}
        <a href="#result-{{minion}}" class="list-group-item">{{ minion }}</a>
        {% endfor %}
      </ul>
    </div>
  </div><!-- /.row -->

  {% for minion in job.info.Minions %}

    {% if job.return.get('data') %}
      {% set job_return = job.return.data %}
    {% else %}
      {% set job_return = job.return %}
    {% endif %}

    {% if job_return.get(minion) is none %}

      <div class="col-lg-12" id="result-{{minion}}">

          <div class="panel panel-danger">
            <div class="panel-heading">
              <h3 class="panel-title">{{ minion }} error:</h3>
            </div>
            <div class="panel-body">
              <p>No return for this minion, minion is down or return is not yet available</p>
            </div>
          </div>
      </div>

    {% else %}

      <div class="col-lg-12" id="result-{{minion}}">
        {{ panel_jsontree(minion + ' result', job_return[minion], False)|safe }}
      </div>

    {% endif %}

    {% endfor %}

{% endblock %}


{% block scripts %}
<script type="text/javascript">
$(function() {
  {{ panel_jsontree_js()|safe }}
  {{ render_trees()|safe }}
});
</script>
{% endblock %}
